package com.happe.foodeasy.helper;

/**
 * This class is used to wrapper params what are variable parameters,
 * and the parameter is couple, column name and value.
 * Created by wubin on 2016-05-12.
 */
public class DaoParamsWrapper {
    private Object[] params;

    public DaoParamsWrapper(Object... params) {
        this.params = params;
    }

    public String[] getColumnNames() {
        if (params == null) {
            return null;
        }
        String[] result = new String[params.length / 2];
        for (int i = 0; i < params.length; i++) {
            if (i % 2 == 0) {
                result[i / 2] = (String) params[i];
            }
        }
        return result;
    }

    public Object[] getParams() {
        if (params == null) {
            return null;
        }
        Object[] result = new Object[params.length / 2];
        for (int i = 0; i < params.length; i++) {
            if ((i % 2) == 1) {
                result[i / 2] = params[i];
            }
        }
        return result;
    }
}
